﻿<Windows:BookvarToolWindow
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:aw="clr-namespace:Assergs.Windows;assembly=Assergs.Windows"
    xmlns:commands="clr-namespace:Bookvar.UI.Commands;assembly=Bookvar.UI"
  xmlns:atp="clr-namespace:Microsoft.Samples.KMoore.WPFSamples.AnimatingTilePanel;assembly=J832.Wpf.BagOTricksLib"
  xmlns:itb="clr-namespace:Microsoft.Samples.KMoore.WPFSamples.InfoTextBox;assembly=J832.Wpf.BagOTricksLib"
  xmlns:local="clr-namespace:BookvarWpf"
  xmlns:controls="clr-namespace:BookvarWpf.Controls"
  xmlns:Windows="clr-namespace:BookvarWpf.Windows;assembly="
  xmlns:r="clr-namespace:Bookvar.UI.Localization;assembly=Bookvar.UI"
	x:Class="BookvarWpf.Windows.LiveImagesWindow"
	Header="{r:Resources LiveImagesHeaderText}"
	Icon="pack://application:,,,/BookvarWPF;component/Resources/Icons/16x16/Search.png"
	Style="{DynamicResource {x:Type aw:ToolWindow}}"
	Width="700" Height="600"
	Background="{StaticResource ListBackground}" 
	>

    <Grid Margin="5">
        <Grid.Resources>
            <Style TargetType="{x:Type TextBox}">
                <Setter Property="HorizontalContentAlignment" Value="Left" />
                <Setter Property="BorderThickness" Value="0,0,0,0" />
                <Setter Property="Margin" Value="2,2,2,2" />
                <Setter Property="Background" Value="Transparent" />
            </Style>

            <Style TargetType="{x:Type Border}">
                <Setter Property="HorizontalAlignment" Value="Left" />
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="BorderBrush" Value="#FF85A7DB" />
                <Setter Property="Background" Value="#FFF0F7FF" />
                <Setter Property="CornerRadius" Value="5,5,5,5" />

                <Setter Property="Height" Value="24" />

                <Setter Property="BorderThickness" Value="1,1,1,1" />
            </Style>

            <Style TargetType="{x:Type Label}">
                <Setter Property="FontFamily" Value="Verdana" />
                <Setter Property="FontSize" Value="10" />
                <Setter Property="Foreground" Value="#FF3E6494" />
                <Setter Property="HorizontalContentAlignment" Value="Left" />
            </Style>


            <ControlTemplate x:Key="templateSlider" TargetType="Slider">

                <!-- Border properties are probably unused -->
                <Border BorderBrush="{TemplateBinding BorderBrush}"
						BorderThickness="{TemplateBinding BorderThickness}"
						Background="{TemplateBinding Background}">

                    <!-- Grid layout accomodates two TickBars and Track -->
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <!-- TickBars are collapsed (invisible) by default) -->
                        <TickBar Grid.Column="0" Name="LeftTick"
								 Width="10" Placement="Left" Visibility="Collapsed"
								 Fill="{TemplateBinding Foreground}" />

                        <TickBar Grid.Column="2" Name="RightTick"
								 Width="10" Placement="Right" Visibility="Collapsed"
								 Fill="{TemplateBinding Foreground}" />

                        <!-- The groove image is provided by this Border -->
                        <Border Grid.Column="1" Height="8" Margin="0" CornerRadius="2 2 2 2"
                    BorderThickness="1" BorderBrush="#FF577FB3">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.486,0.72" StartPoint="1.155,0.662">
                                    <GradientStop Color="#FFFF7000" Offset="0"/>
                                    <GradientStop Color="#00FF0000" Offset="0.995"/>
                                </LinearGradientBrush>
                            </Border.Background>
                        </Border>

                        <!-- That same Grid cell is occupied by the Track -->
                        <Track Grid.Column="1" Name="PART_Track">
                            <Track.DecreaseRepeatButton>
                                <!-- The two RepeatButtons are transparent -->
                                <RepeatButton Command="Slider.DecreaseLarge"
											  IsTabStop="False" Focusable="False">
                                    <RepeatButton.Template>
                                        <ControlTemplate>
                                            <Border Background="Transparent" />
                                        </ControlTemplate>
                                    </RepeatButton.Template>
                                </RepeatButton>
                            </Track.DecreaseRepeatButton>

                            <Track.IncreaseRepeatButton>
                                <RepeatButton Command="Slider.IncreaseLarge"
											  IsTabStop="False" Focusable="False">
                                    <RepeatButton.Template>
                                        <ControlTemplate>
                                            <Border Background="Transparent" />
                                        </ControlTemplate>
                                    </RepeatButton.Template>
                                </RepeatButton>
                            </Track.IncreaseRepeatButton>
                            <Track.Thumb>
                                <Thumb >
                                    <Thumb.Template>
                                        <ControlTemplate>
                                            <Border Background="Transparent">
                                                <Rectangle Stroke="#FF577FB3" StrokeThickness="1" HorizontalAlignment="Left"
														   VerticalAlignment="Top" Width="8" Height="24">
                                                    <Rectangle.Fill>
                                                        <LinearGradientBrush EndPoint="0.486,0.72" StartPoint="0.486,-0.002">
                                                            <GradientStop Color="#FFA3C2E8" Offset="0"/>
                                                            <GradientStop Color="#FF8FAFD9" Offset="0.908"/>
                                                            <GradientStop Color="#FF8FAFD9" Offset="0.485"/>
                                                            <GradientStop Color="#FFFCFBED" Offset="0.67"/>
                                                        </LinearGradientBrush>
                                                    </Rectangle.Fill>
                                                </Rectangle>
                                            </Border>
                                        </ControlTemplate>
                                    </Thumb.Template>
                                </Thumb>
                            </Track.Thumb>
                        </Track>
                    </Grid>
                </Border>

                <!-- Define triggers to make the TickBars visible -->
                <ControlTemplate.Triggers>
                    <Trigger Property="Slider.TickPlacement" Value="TopLeft">
                        <Setter TargetName="LeftTick" Property="Visibility"
													  Value="Visible" />
                    </Trigger>
                    <Trigger Property="Slider.TickPlacement" Value="BottomRight">
                        <Setter TargetName="RightTick" Property="Visibility"
													   Value="Visible" />
                    </Trigger>
                    <Trigger Property="Slider.TickPlacement" Value="Both">
                        <Setter TargetName="LeftTick" Property="Visibility"
													  Value="Visible" />
                        <Setter TargetName="RightTick" Property="Visibility"
													   Value="Visible" />
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>

            <!-- Define style for the Slider control -->
            <Style x:Key="styleSlider" TargetType="Slider">
                <Setter Property="Orientation" Value="Horizontal" />
                <Setter Property="Template"
						Value="{StaticResource templateSlider}" />
            </Style>

        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <Border Grid.Row="0" Grid.Column="1" Width="Auto" >
            <itb:InfoTextBox x:Name="txtSearch" Width="300" BorderThickness="0,0,0,0" TextBoxInfo="{r:Resources LiveImagesSearchText}" />
        </Border>
        <StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal">
            <Label  Content="Image Size:" Padding="0,0,10,0" VerticalAlignment="Center" />
            <Slider x:Name="sliderSize" Width="200"  Minimum="50" Maximum="300" SmallChange="40" Value="150"
					Style="{StaticResource styleSlider}" HorizontalAlignment="Center" />
        </StackPanel>
        <ScrollViewer Grid.Row="1" Grid.ColumnSpan="2" Padding="0,5,0,0">
            <ItemsControl x:Name="imagesItemsControl">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <atp:AnimatingTilePanel ItemHeight="{Binding ElementName=sliderSize, Path=Value}" ItemWidth="{Binding ElementName=sliderSize, Path=Value}"  />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Image Source="{Binding Path=ThumbnailUri}" DataContext="{Binding}" PreviewMouseDown="Image_PreviewMouseDown">
                            <Image.ToolTip>
                                <TextBlock Text="{Binding Path=Title}" />
							</Image.ToolTip>
                        </Image>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>

        </ScrollViewer>

        <controls:ProgressAnimation x:Name="progressAnimation" Margin="120,30,30,30" Grid.Row="1" />

    </Grid>
</Windows:BookvarToolWindow>